package com.vint.mi;

import com.vint.common.StringCommons;

/**
 * 1.done
 * 2.easy
 *
 */
public class Mi38 {
    public static String solution(String line){
        int[] sr = StringCommons.StringToIns(line);
        return Integer.toString(minLeap(sr));
    }

    public static int[] me = new int[100];
    private static int minLeap(int[] src){
        int n = src.length;
        if(n==1)return 0;
        if(src[0]==0)return -1;
        me[0] = 0;
        int min = -1;
        for(int i=1;i<n;i++){
            min = -1;
            for(int j=0; j<i; j++){
                if(src[j]==-1)continue;
                if(i-j<=src[j]){
                    if(min==-1) {
                        min = me[j] + 1;
                    }else{
                       if(min>me[j]+1){
                           min = me[j] +1;
                       }
                    }
                }
            }
            me[i] = min;
        }
        return me[n-1];
    }
    public static void main(String[] args) {
        //System.out.println(solution("2,3,1,1,4"));
        System.out.println(solution("1,0,3,0,0,2,1,1,0,4,0,1,3,2,4"));
        System.out.println(solution("1,1,1,0,1"));
        System.out.println(solution("0,0,3,10,6,10,8,9,1,7,3,10,5,8,6,1,7,0,0,3,6,7,4,10,8,1,3,6,3,5,10,3,6,2,2,1,2,0,10,3"));
    }
}
